use std::ffi;

use raw_window_handle as raw;

pub struct WinRaw {
	view: *mut ffi::c_void,
}
impl From<*mut ffi::c_void> for WinRaw {
	fn from(value: *mut ffi::c_void) -> Self {
		Self { view: value }
	}
}
unsafe impl Send for WinRaw {}
unsafe impl Sync for WinRaw {}
impl raw::HasWindowHandle for WinRaw {
	fn window_handle(&self) -> Result<raw::WindowHandle<'_>, raw::HandleError> {
		if let Some(view) = std::ptr::NonNull::new(self.view) {
			Ok(unsafe { raw::WindowHandle::borrow_raw(raw::RawWindowHandle::AndroidNdk(raw::AndroidNdkWindowHandle::new(view))) })
		} else {
			Err(raw::HandleError::Unavailable)
		}
	}
}
impl raw::HasDisplayHandle for WinRaw {
	fn display_handle(&self) -> Result<raw::DisplayHandle<'_>, raw::HandleError> {
		Ok(unsafe { raw::DisplayHandle::borrow_raw(raw::RawDisplayHandle::Android(raw::AndroidDisplayHandle::new())) })
	}
}
